use C:\Downloads\leafletsGE2015.dta 
********************************************************************************
*******FIGURE 1
********************************************************************************
bys seat: tab numleaf

********************************************************************************
*******FIGURE 2
********************************************************************************
bys party: tab leadphoto

**Download Wave 4 of the British Election Study at http://www.britishelectionstudy.com/data-objects/panel-study-data/
use C:\Downloads\BES2015_W4_v3.7.dta 
svyset _n [pweight=wt_full_W4], vce(linearized) singleunit(missing)
recode likeCameron 0/4=-1 5=0 6/10=1 else=., g(like_cameron)
recode likeMiliband 0/4=-1 5=0 6/10=1 else=., g(like_miliband)
recode likeClegg 0/4=-1 5=0 6/10=1 else=., g(like_clegg)
recode likeSturgeon 0/4=-1 5=0 6/10=1 else=., g(like_sturgeon)
recode likeFarage 0/4=-1 5=0 6/10=1 else=., g(like_farage)
recode likeBennett 0/4=-1 5=0 6/10=1 else=., g(like_bennett)

svy: tab like_sturgeon if partyId==4
svy: tab like_sturgeon 
svy: tab like_cameron 
svy: tab like_cameron if partyId==1
svy: tab like_bennett 
svy: tab like_bennett if partyId==7
svy: tab like_farage 
svy: tab like_farage if partyId==6
svy: tab like_miliband 
svy: tab like_miliband if partyId==2
svy: tab like_clegg 
svy: tab like_clegg if partyId==3


********************************************************************************
*******TABLE 2
********************************************************************************
ttest leadphoto if marginal==1, by(abovemedianlike)
ttest leadphoto if marginal==0, by(abovemedianlike)
ttest leadphoto, by(incumbent)
ttest leadphoto, by(longinparl)
ttest leadphoto, by(candlocties)	
	
********************************************************************************
*******TABLE 3
********************************************************************************

logit leadphoto  pty_conserv pty_libdem pty_snp pty_ukip pty_green, robust
estat classification

logit leadphoto  c.like_leader##c.Majority10,robust
estat classification

logit leadphoto  incumbent  candlocties if ptycand==1, robust
estat classification

logit leadphoto  longinparl candlocties if ptycand==1, robust
estat classification

logit leadphoto  pty_conserv pty_libdem pty_snp pty_ukip pty_green c.like_leader##c.Majority10 incumbent candlocties if ptycand==1, robust
estat classification


********************************************************************************
*******TABLE 4
********************************************************************************

**Conservatives**
quietly: logit leadphoto  pty_conserv pty_libdem pty_snp pty_ukip pty_green c.like_leader##c.Majority10 incumbent candlocties if ptycand==1
margins, at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=0 ) ///
at(pty_conserv=1 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=0) atmeans vsquish post
test _b[1._at] = _b[2._at]

**Lib Dems**
quietly: logit leadphoto  pty_conserv pty_libdem pty_snp pty_ukip pty_green c.like_leader##c.Majority10 incumbent candlocties if ptycand==1
margins, at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=0 ) ///
at(pty_conserv=0 pty_libdem=1 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=0) atmeans vsquish post
test _b[1._at] = _b[2._at]

**SNP**
quietly: logit leadphoto  pty_conserv pty_libdem pty_snp pty_ukip pty_green c.like_leader##c.Majority10 incumbent candlocties if ptycand==1
margins, at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=0 ) ///
at(pty_conserv=0 pty_libdem=0 pty_snp=1 pty_ukip=0 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=0) atmeans vsquish post
test _b[1._at] = _b[2._at]

**UKIP**
quietly: logit leadphoto  pty_conserv pty_libdem pty_snp pty_ukip pty_green c.like_leader##c.Majority10 incumbent candlocties if ptycand==1
margins, at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=0 ) ///
at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=1 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=0) atmeans vsquish post
test _b[1._at] = _b[2._at]

**Greens**
quietly: logit leadphoto  pty_conserv pty_libdem pty_snp pty_ukip pty_green c.like_leader##c.Majority10 incumbent candlocties if ptycand==1
margins, at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=0 ) ///
at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=1 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=0) atmeans vsquish post
test _b[1._at] = _b[2._at]

**Local popularity � Marginal seat**
quietly: logit leadphoto  pty_conserv pty_libdem pty_snp pty_ukip pty_green c.like_leader##c.Majority10 incumbent candlocties if ptycand==1
margins, at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=1.3 Majority10=2.4 incumbent=0 candlocties=0 ) ///
at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=6.7 Majority10=2.4 incumbent=0 candlocties=0) atmeans vsquish post
test _b[1._at] = _b[2._at]

**Local popularity � Safe seat**
quietly: logit leadphoto  pty_conserv pty_libdem pty_snp pty_ukip pty_green c.like_leader##c.Majority10 incumbent candlocties if ptycand==1
margins, at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=1.3 Majority10=30.9 incumbent=0 candlocties=0 ) ///
at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=6.7 Majority10=30.9 incumbent=0 candlocties=0) atmeans vsquish post
test _b[1._at] = _b[2._at]

**Incumbency**
quietly: logit leadphoto  pty_conserv pty_libdem pty_snp pty_ukip pty_green c.like_leader##c.Majority10 incumbent candlocties if ptycand==1
margins, at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=0 ) ///
at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=1 candlocties=0) atmeans vsquish post
test _b[1._at] = _b[2._at]

**Local ties**
quietly: logit leadphoto  pty_conserv pty_libdem pty_snp pty_ukip pty_green c.like_leader##c.Majority10 incumbent candlocties if ptycand==1
margins, at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=0 ) ///
at(pty_conserv=0 pty_libdem=0 pty_snp=0 pty_ukip=0 pty_green=0 like_leader=3.8 Majority10=15.9 incumbent=0 candlocties=1) atmeans vsquish post
test _b[1._at] = _b[2._at]

********************************************************************************
*******TABLE A1
********************************************************************************
tab party
